//
//  HWPersonInformationCell.m
//  嗨文
//
//  Created by 响当当 on 2019/1/17.
//  Copyright © 2019年 dongzheng. All rights reserved.
//

#import "HWPersonInformationCell.h"

@interface HWPersonInformationCell()
@property (nonatomic, strong)UILabel *titlelabel;//标题
@property (nonatomic, strong)UILabel *subTitleLabel;//内容
@property (nonatomic, strong)UIView *lineView;//下划线
@end

@implementation HWPersonInformationCell

- (UILabel *)titlelabel
{
    if (!_titlelabel)
    {
        _titlelabel = [HWUtilties creatLabelWithFrame:CGRectMake(18*kUIScaleBasePlus,16*kUIScaleBasePlus,120*kUIScaleBasePlus,13*kUIScaleBasePlus)
                                         textAligment:NSTextAlignmentLeft
                                             textClor:LCHexColor(0x212121)
                                             textFont:14*kUIScaleBasePlus];
    }
    return _titlelabel;
}

- (UILabel *)subTitleLabel
{
    if (!_subTitleLabel)
    {
        _subTitleLabel = [HWUtilties creatLabelWithFrame:CGRectMake(SCREEN_WIDTH-16*kUIScaleBasePlus,16*kUIScaleBasePlus,0, 13*kUIScaleBasePlus)
                                            textAligment:NSTextAlignmentRight
                                                textClor:LCHexColor(0x7A8C9B)
                                                textFont:14*kUIScaleBasePlus];
    }
    return _subTitleLabel;
}

- (UIView *)lineView
{
    if (!_lineView)
    {
        _lineView = [[UIView alloc]initWithFrame:CGRectMake(0,45*kUIScaleBasePlus,SCREEN_WIDTH,1*kUIScaleBasePlus)];
        _lineView.backgroundColor = LCHexColor(0xEBE5E1);
    }
    return _lineView;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self.contentView addSubview:self.titlelabel];
        [self.contentView addSubview:self.subTitleLabel];
        [self.contentView addSubview:self.lineView];
    }
    return self;
}

#pragma mark - 获取个人信息数据
- (void)getPersonInfoTitle:(NSString *)title andSubTitle:(NSString *)subTitle
{
    
    self.titlelabel.text = title;
    
    if ([subTitle isValidString])
    {
        if ([title isEqualToString:@"性别"])
        {
            self.subTitleLabel.text = [subTitle isEqualToString:@"1"] ? @"男": @"女";
        }
        else if([title isEqualToString:@"阅读章节自动购买"])
        {
            self.subTitleLabel.text = [subTitle isEqualToString:@"0"] ? @"否": @"是";
        }
        else
        {
            self.subTitleLabel.text = subTitle;
        }
        
        [self.subTitleLabel sizeToFit];
        
        if ([title isEqualToString:@"性别"] || [title isEqualToString:@"阅读章节自动购买"])
        {
            [self.subTitleLabel setX:SCREEN_WIDTH-self.subTitleLabel.frame.size.width-29*kUIScaleBasePlus];
        }
        else
        {
            [self.subTitleLabel setX:SCREEN_WIDTH-self.subTitleLabel.frame.size.width-16*kUIScaleBasePlus];
        }
    }
    
    if ([title isEqualToString:@"切换账号"] || [title isEqualToString:@"退出"])
    {
        UIView *bgView = [[UIView alloc]initWithFrame:CGRectMake(0,0,SCREEN_WIDTH,10*kUIScaleBasePlus)];
        bgView.backgroundColor = LCHexColor(0xF5F5F5);
        [self.contentView addSubview:bgView];
        
        self.titlelabel.frame = CGRectMake(0,10*kUIScaleBasePlus,SCREEN_WIDTH,46*kUIScaleBasePlus);
        self.titlelabel.textAlignment = NSTextAlignmentCenter;
        self.subTitleLabel.frame = CGRectZero;
        [self.lineView setY:55*kUIScaleBasePlus];
    }
}
@end
